package com.ice.day726.thread;

import lombok.extern.slf4j.Slf4j;

import static java.lang.Thread.sleep;

/**
 * @Author ice2020x
 * @Date 2022-08-01 15:45
 * @Description: 打断sleep的线程
 */
@Slf4j
public class ThreadTest10 {

    public static void main(String[] args) {

        Thread t1 = new Thread(()->{
            log.debug("sleep...");
            try {
                sleep(5000);
            } catch (InterruptedException e) {
                log.debug("打断了");
                e.printStackTrace();
            }
        });


        t1.start();

        try {
            sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.debug("interrupt...");
        t1.interrupt();
        log.debug("打断标记{}",t1.isInterrupted());
    }
}
